/**
 * Date: 2022/1/4
 * Author: january
 * Description: 
 */

#include <libecc/cipher/cipher_algs.h>
#include <libecc/utils/log.h>
#include <stdio.h>
#include <string.h>

int main() {
    uint8_t key[16];
    uint8_t iv[16];
    uint8_t org[128];
    uint8_t enc[128];
    uint8_t dec[128];

    memset(key, 0x1, 16);
    memset(iv, 0x2, 16);
    memset(org, 0x3, 128);
    cipher_context ctx;
    const cipher_mapping* cipher = get_cipher_by_name("sm4_ctr");

    LOG_INFO_MEM(org, 128, "Org data");
    cipher->enc_init(&ctx, iv, 16, key, 16);
    cipher->enc(&ctx, org, 128, enc);
    LOG_INFO_MEM(enc, 128, "Encrypted data");
    cipher->dec_init(&ctx, iv, 16, key, 16);
    cipher->dec(&ctx, enc, 128, dec);
    LOG_INFO_MEM(dec, 128, "Decrypted data");
}

